/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package formula.one.urjc.principal.view;

import formula.one.urjc.Metodos;
import formula.one.urjc.admin.controlador.AdminEscuderiaControl;
import formula.one.urjc.admin.view.VentanaAminEscuderia;
import formula.one.urjc.circuito.view.AltaCircuito;
import formula.one.urjc.circuito.view.BajaCircuito;
import formula.one.urjc.circuito.view.ModificarCircuito;
import formula.one.urjc.piloto.view.AltaPiloto;
import formula.one.urjc.piloto.view.BajaPiloto;
import formula.one.urjc.piloto.view.ModificarPiloto;

/**
 *
 * @author santiago
 */
public class ventanaAdministrador extends javax.swing.JFrame {

    /**
     * Creates new form ventanaAdministrador
     */
    public ventanaAdministrador() {
        initComponents();
        //Redimensionamos la ventana
        //setLocationRelativeTo(null);        // Centering on screen...
        //setSize(550, 600);                  // Setting dimensions...
    }
    
    public void cerrarVentanas() {
        ventanasGestion.removeAll() ;
        ventanasGestion.updateUI() ; 
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ventanasGestion = new javax.swing.JDesktopPane();
        jMenuBar1 = new javax.swing.JMenuBar();
        gestionEscuderias = new javax.swing.JMenu();
        Gestión = new javax.swing.JMenuItem();
        gestionarPilotos = new javax.swing.JMenu();
        altaPiloto = new javax.swing.JMenuItem();
        bajaPiloto = new javax.swing.JMenuItem();
        modificarPiloto = new javax.swing.JMenuItem();
        bajaCircuitos = new javax.swing.JMenu();
        altaCircuito = new javax.swing.JMenuItem();
        modificacionCircuitos = new javax.swing.JMenuItem();
        modificacionCircuito = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        gestionEscuderias.setText("Escuderías");

        Gestión.setText("Gestión");
        Gestión.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GestiónActionPerformed(evt);
            }
        });
        gestionEscuderias.add(Gestión);

        jMenuBar1.add(gestionEscuderias);

        gestionarPilotos.setText("Pilotos");

        altaPiloto.setText("Alta");
        altaPiloto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                altaPilotoActionPerformed(evt);
            }
        });
        gestionarPilotos.add(altaPiloto);

        bajaPiloto.setText("Baja");
        bajaPiloto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bajaPilotoActionPerformed(evt);
            }
        });
        gestionarPilotos.add(bajaPiloto);

        modificarPiloto.setText("Modificación");
        modificarPiloto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                modificarPilotoActionPerformed(evt);
            }
        });
        gestionarPilotos.add(modificarPiloto);

        jMenuBar1.add(gestionarPilotos);

        bajaCircuitos.setText("Circuitos");

        altaCircuito.setText("Alta");
        altaCircuito.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                altaCircuitoActionPerformed(evt);
            }
        });
        bajaCircuitos.add(altaCircuito);

        modificacionCircuitos.setText("Baja");
        modificacionCircuitos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                modificacionCircuitosActionPerformed(evt);
            }
        });
        bajaCircuitos.add(modificacionCircuitos);

        modificacionCircuito.setText("Modificación");
        modificacionCircuito.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                modificacionCircuitoActionPerformed(evt);
            }
        });
        bajaCircuitos.add(modificacionCircuito);

        jMenuBar1.add(bajaCircuitos);

        jMenu1.setText("Log Out");
        jMenu1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenu1MouseClicked(evt);
            }
        });
        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ventanasGestion, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ventanasGestion, javax.swing.GroupLayout.DEFAULT_SIZE, 646, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void GestiónActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GestiónActionPerformed
        // TODO add your handling code here:
        // Removemos las ventanas
        cerrarVentanas() ;
        AdminEscuderiaControl control=new AdminEscuderiaControl(new VentanaAminEscuderia(), new Metodos());
        // Abrimos la ventana de Gestión Escuderías
        //VentanaAminEscuderia vae = new VentanaAminEscuderia() ;
        ventanasGestion.add(control.mostrarVentana()) ;
        //vae.show() ;
    }//GEN-LAST:event_GestiónActionPerformed

    private void altaPilotoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_altaPilotoActionPerformed
        // TODO add your handling code here:
        // Removemos las ventanas
        cerrarVentanas() ;
        // Abrimos la ventana de Alta de Piloto
        AltaPiloto ap = new AltaPiloto() ;
        ventanasGestion.add(ap) ;
        ap.show() ;
    }//GEN-LAST:event_altaPilotoActionPerformed

    private void modificarPilotoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modificarPilotoActionPerformed
        // TODO add your handling code here:
        // Removemos las ventanas
        cerrarVentanas() ;
        // Abrimos la ventana de Modificación de Piloto
        ModificarPiloto mp = new ModificarPiloto() ;
        ventanasGestion.add(mp) ;
        mp.show() ;
    }//GEN-LAST:event_modificarPilotoActionPerformed

    private void bajaPilotoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bajaPilotoActionPerformed
        // TODO add your handling code here:
        // Removemos las ventanas
        cerrarVentanas() ;
        // Abrimos la ventana de Baja de Piloto
        BajaPiloto bp = new BajaPiloto() ;
        ventanasGestion.add(bp) ;
        bp.show() ;
    }//GEN-LAST:event_bajaPilotoActionPerformed

    private void altaCircuitoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_altaCircuitoActionPerformed
        // TODO add your handling code here:
        // Removemos las ventanas
        cerrarVentanas() ;
        // Abrimos la ventana de Alta de Circuito
        AltaCircuito ac = new AltaCircuito() ;
        ventanasGestion.add(ac) ;
        ac.show() ;        
    }//GEN-LAST:event_altaCircuitoActionPerformed

    private void modificacionCircuitoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modificacionCircuitoActionPerformed
        // TODO add your handling code here:
        // Removemos las ventanas
        cerrarVentanas() ;
        // Abrimos la ventana de Modificación de Circuito
        ModificarCircuito mc = new ModificarCircuito() ;
        ventanasGestion.add(mc) ;
        mc.show() ;
    }//GEN-LAST:event_modificacionCircuitoActionPerformed

    private void modificacionCircuitosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modificacionCircuitosActionPerformed
        // TODO add your handling code here:
        // Removemos las ventanas
        cerrarVentanas() ;
        // Abrimos la ventana de Baja de CIrcuito
        BajaCircuito bc = new BajaCircuito() ;
        ventanasGestion.add(bc) ;
        bc.show() ;
    }//GEN-LAST:event_modificacionCircuitosActionPerformed

    private void jMenu1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenu1MouseClicked
        dispose();
        Login vL=new Login();
        vL.setLocationRelativeTo(null);
        vL.setVisible(true);
    }//GEN-LAST:event_jMenu1MouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ventanaAdministrador.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ventanaAdministrador.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ventanaAdministrador.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ventanaAdministrador.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ventanaAdministrador().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem Gestión;
    private javax.swing.JMenuItem altaCircuito;
    private javax.swing.JMenuItem altaPiloto;
    private javax.swing.JMenu bajaCircuitos;
    private javax.swing.JMenuItem bajaPiloto;
    private javax.swing.JMenu gestionEscuderias;
    private javax.swing.JMenu gestionarPilotos;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem modificacionCircuito;
    private javax.swing.JMenuItem modificacionCircuitos;
    private javax.swing.JMenuItem modificarPiloto;
    private javax.swing.JDesktopPane ventanasGestion;
    // End of variables declaration//GEN-END:variables
}
